<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-body">
        <div style="display: flex;">
            <img width="150" onclick="showimg(this)" id="cover_img" src="" alt="">
            <div style="margin-left: 10px;">
                <p>短剧名称：<span id="name"></span></p>
                <p>描述：<span id="synopsis"></span></p>
            </div>
        </div>
        <table id="detail" lay-filter="detail"></table>
    </div>
    
    <script type="text/html" id="tbBar">
        {{#
            let tem = ``;
            if(is_distributor !== 1 && is_branch_office_manage !== 1){
                tem +=  `
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="look">播放</a>
                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="link">获取推广链接</a>
                `
            }else{
                tem +=  `
                    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="look">播放</a>
                `
            }
            if(d.is_download === 1){
                tem += `
                <a class="layui-btn layui-btn-xs" lay-event="download">下载</a>
                `
            }
            return tem
        }}
        <!-- {{#  if(d.is_set_follow_drama === 1 ){ }}
            <a class="layui-btn layui-btn-success layui-btn-xs" lay-event="FollowDrama">取消关注剧集</a>
        {{#  } else { }}
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="FollowDrama">设为关注剧集</a>
        {{#  } }} -->
    </script>
    <script>
        let params = {
            elem: '#detail'
            , toolbar: false
            , url: `/cps/video/detail?video_id=${GetQueryString('id')}` //数据接口
            , id: 'detail'
            , page:false
            , cols: [[ //表头
                { field: 'id', title: '剧集ID', width: 200, sort: true, align:'center' }
                , { field: 'sort', title: '章节名称', templet: function (d) {
                        return `第${d.sort}集`
                    },align:'center'
                }
                , { toolbar: '#tbBar', title: '操作', align:'center',width:240}
            ]]
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(detail)', function (obj) {
                var event = obj.event;
                if (event === 'look') {
                    x_admin_show('', obj.data.url, 1050, 500,0,false);
                }else if(event === 'FollowDrama') {
                    ChangeAjax('/cps/video/setFollowDrama',{ video_detail_id: obj.data.id},'detail')
                }else if(event === 'link') {
                    x_admin_show('获取推广链接', `../link/info.html?video_detail_id=${obj.data.id}&video_id=${GetQueryString('id')}&video_name=${GetQueryString('video_name')}&sort=${obj.data.sort}`, 800, 550);
                }else if(event === 'download') {
                    var data = `id=${obj.data.id}`;
                    window.open(`/cps/video/downloadVideo?${data}&token=${token}`, '_self')
                }
            });

        });
        $('#cover_img').attr('src',GetQueryString('cover_img'))
        $('#name').html(decodeURI(GetQueryString('video_name')))
        $('#synopsis').html(decodeURI(GetQueryString('synopsis')) == 'null' ? '空' : decodeURI(GetQueryString('synopsis')))
    </script>
</body>

</html>